package com.sosee.cgfw.friends;

import com.sosee.cgfw.utils.Constans;
import com.sosee.cgfw.utils.Utils;
import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Thinkpad on 2016/3/11.
 */
public class friendsListUtils {

    static HttpUtils httpUtils;
    public static  List<FriendsListData.Data> datas;
    static List<String> cityName = new ArrayList<String>();

    public static void request() {

        httpUtils= new HttpUtils();
        httpUtils.send(HttpRequest.HttpMethod.GET, Constans.GETFRIENDSLIST_URL+Constans.userID, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                String result = responseInfo.result;
                System.out.println("我是好友列表返回的数据：" + result);


                Gson gson = new Gson();
                FriendsListData friendsListData = gson.fromJson(result, FriendsListData.class);
                if("success".equals(friendsListData.getStatus())){

                    datas = friendsListData.getData();

                    for (int i = 0; i < datas.size(); i++) {
                        String ID = datas.get(i).getFriends().getID();
                        //吧名字赋值给name
                        cityName.add(ID);
                    }


                }else{

                }

            }
//            return cityName;
            @Override
            public void onFailure(HttpException e, String s) {
                Utils.showToast("网络加载异常");
            }
        });

    }

}
